package com.crm.service.impl.returnMoney;

import com.crm.common.model.Enum.StatusCodeEnum;
import com.crm.dao.mapper.customMapper.returnMoneyManagerCustomMapper.ReturnMoneyExamineCustomMapper;
import com.crm.dao.mapper.returnMoney.ReturnMoneyExamineMapper;
import com.crm.model.entity.returnMoney.ReturnMoneyExamine;
import com.crm.model.entity.returnMoney.ReturnMoneyExamineExample;
import com.crm.model.qo.returnMoney.ReturnMoneyExamineQO;
import com.crm.model.vo.returnMoney.ReturnMoneyExamineVO;
import com.crm.service.returnMoney.ReturnMoneyExamineDbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReturnMoneyExamineDbServiceImpl implements ReturnMoneyExamineDbService {

    @Autowired
    private ReturnMoneyExamineMapper returnMoneyExamineMapper;
    @Autowired
    private ReturnMoneyExamineCustomMapper returnMoneyExamineCustomMapper;

    @Override
    public List<ReturnMoneyExamineVO> selectList(ReturnMoneyExamineQO returnMoneyExamineQO) {
        return returnMoneyExamineCustomMapper.selectList(returnMoneyExamineQO);
    }

    @Override
    public ReturnMoneyExamine selectByPrimaryKey(String examineId) {
        return returnMoneyExamineMapper.selectByPrimaryKey(examineId);
    }

    @Override
    public int updateByPrimaryKeySelective(ReturnMoneyExamine returnMoneyExamine) {
        return returnMoneyExamineMapper.updateByPrimaryKeySelective(returnMoneyExamine);
    }

    @Override
    public ReturnMoneyExamineVO selectByExamineId(String examineId) {
        return returnMoneyExamineCustomMapper.selectByExamineId(examineId);
    }

    /**
     * 回款未审核
     * @Author renshaorong
     * @Date 2021/12/17
     * @return
     */
    @Override
    public Integer getReturnMoneyExamineNum() {
        ReturnMoneyExamineExample example = new ReturnMoneyExamineExample();
        example.or().andDeleteStatusEqualTo(Short.parseShort(String.valueOf(StatusCodeEnum.NORMAL_CODE.getState())))
                .andExamineStateEqualTo((short)0);
        return returnMoneyExamineMapper.selectByExample(example).size();
    }
}
